<!DOCTYPE html>
<html>

<head>
    <head/>
    <title>科室详情</title>
    <titleType style="display: none;">ksDetail</titleType>
    <%- include('./_global/appendJs') %>
</head>
<style>
    .swiper-wrapper .swiper-slide {
        float: left;
    }

    .docSpecialty {
        height: 24px;
    }

    .remove-header {
        top: 0 !important;
    }

    .doctor-detail .check-date-box .swiper-slide {
        width: calc(14.2% - 0.25rem);
    }

    .numInfo {
        width: calc(100% - 4.9rem - 60%);
        float: right;
        height: auto;
        text-align: center;
        margin-top: 1rem;
    }

    .numInfo span {
        bottom: 0.2rem;
        position: absolute;
        text-align: center;
    }

    .office-box .office-list-box>ul>li.outpatient-service {
        padding: 2.55rem 1.25rem 2.55rem 1.2rem;
    }

    .office-box .office-list-box>ul>li.outpatient-service>.docImgUrl {
        position: relative;
        top: -1.5rem;
    }

    .office-box .office-list-box>ul>li img {
        margin-top: .5rem;
    }
    .office-box .office-list-box>ul>li.outpatient-service .numInfo {
        margin-top: -.4rem;
    }
</style>


<body>
    <section class="page-wrap office-box">
        <!-- <header class="header-box grey fixed">
            <div class="header-content">
                <div class="left-tool">
                    <a class="back" href="javascript:void(0);">
                        <i class="iconfont icon-back"></i>
                    </a>
                </div>
                <div class="title">科室详情</div>
            </div>
        </header> -->
        <!--  <section class="page-wrap hospital-detail">
        <div class="hospital-tab-box">
            <ul class="row" id="ListTab">
                <li class="col-xs-6 active"  index="0">
                    <a>按专家预约</a>
                </li>
                <li class="col-xs-6"   index="1">
                    <a>按日期预约</a>
                </li>
            </ul>
        </div>
    </section> -->
        <div id="ListTabBox">
            <div class="office-list-box tab active" index="0" id="docDiv">
                <ul id="docUl">
                </ul>
            </div>

            <div class="page-wrap doctor-detail tab" index='1' style="display: none">
                <div id="sliderTimer" class="check-date-box swiper-container swiper-container-horizontal swiper-container-free-mode">
                    <div class="swiper-wrapper" style="transform: translate3d(0px, 0px, 0px);height:60px;" id="timeSchedule">
                    </div>
                </div>
                <div id="ListTabBox">
                    <div class="office-list-box" index="0" id="docDiv">
                        <ul id="datedocUl">
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>
</body>
<script src="/static/lib/forweb.js"></script>
<script src="/quickJs/scripts/swiper/3.4.2/js/swiper.min.js"></script>
<script src="/static/js/<%=type%>/pageUrl.js"></script>
<script src="/static/js/<%=type%>/yygh.js"></script>
<script type="text/html" id="docyhLi">
    <li>
        <img class="docImgUrl" src="images/doctor4.png">
        <div class="text-box">
            <span class="blue-text docName">布朗</span>
            <span class="sub-text docTitle">副主任医师</span>
            <span class="docSpecialty"></span>
        </div>
        <div class="numInfo">
            <a class="blue-yy active" href="javascript:void(0);">预约</a>
            <!--<span class="fee"></span>-->
        </div>

    </li>
</script>
<script type="text/html" id="outpatientInfo">
    <li class="outpatient-service">
        <img class="docImgUrl" src="/static/images/icon_ptmz.png">
        <div class="text-box">
            <span class="blue-text docName">{{depName}}</span>
        </div>
        <div class="numInfo">
            <a class="blue-yy active" href="javascript:void(0);">预约</a>
            <!--<span class="fee"></span>-->
        </div>
    </li>
</script>
<script type="text/html" id="outpatientInfo1">
    <li class="outpatient-service">
        <img class="docImgUrl" src="/static/images/doctor_image.jpg">
        <div class="text-box">
            <span class="blue-text docName">专家组</span>
        </div>
        <div class="numInfo">
            <a class="blue-yy active" href="javascript:void(0);">预约</a>
            <!--<span class="fee"></span>-->
        </div>
    </li>
</script>
<!--<script type="text/html" id="docwhLi">-->
<!--<li>-->
<!--<img class="docImgUrl" src="">-->
<!--<div class="text-box">-->
<!--<span class="blue-text docName">布朗</span>-->
<!--<span class="sub-text docTitle">副主任医师</span>-->
<!--<span> </span>-->
<!--<span> </span>-->
<!--</div>-->
<!--<a class="blue-yy" href="javascript:void(0);">约满</a>-->
<!--</li>-->
<!--</script>-->
<script type="text/html" id="dateDiv">
    <div class="swiper-slide swiper-slide-active">
        <div class="time-wrap">
            <p class="text-week">周日</p>
            <p class="text-time">2016-09-29</p>
        </div>
    </div>
</script>
<script type="text/html" id="noInfo">
    <li class="yysj">
        <div class="text-box" style="width: 100%;margin-left: 0;">
            <div class="docSpecialty" style="text-align: center;">暂无医生</div>
        </div>
    </li>
</script>
<script type="text/javascript">
    var docType = 'expert';
    var yygh_ksinfo = StoreCache.getCache("YYGH_KSINFO");

    function toYsDetail(ysInfo) {
        var data = docType != "expert" ? "selectTime=" + docType : "";
        StoreCache.setCache("YYGH_YSINFO", JSON.parse(ysInfo));
        $.pageSwitch.goToUrl("myOrder", "docDetail", data);

    }

    var page_ksDetail = (function ($, page_ksDetail) {

        

        /**加载视图*/
        function initView() {
            /**移动端进入删除改变定位的top*/
            if (ServiceType == "mobile") {
                $(".filtrate-sub-check").addClass("remove-header");
            }

            if ($.QuickVersion["isWeixin"]) {
                $("#weixinSx").show();
            }




            /**号源类型*/
            $("#hylx").on("click", function () {
                $(this).parents("li").siblings().find(".filtrate-sub-check").hide();
                $("#hylxChildren").toggle();
            });

            $("#hylxChildren").on("click", "li", function () {
                if (!$(this).hasClass("active")) {
                    $(this).siblings("li").removeClass("active");
                    $(this).addClass("active");
                    $(this).parents(".filtrate-sub-check").hide();
                    var val = $(this).attr("value");
                    $(".sxxx").find(".hylx").removeClass("active");
                    $(".sxxx").find(".hylx[value='" + val + "']").addClass("active");
                    /**加载医生信息*/
                    page_ksDetail.initDocInfo();


                }
            })


            /**医生职称*/
            $("#yszc").on("click", function () {
                $(this).parents("li").siblings().find(".filtrate-sub-check").hide();
                $("#yszcChildren").toggle();
            });


            $("#yszcChildren").on("click", "li", function () {
                if (!$(this).hasClass("active")) {
                    $(this).siblings("li").removeClass("active");
                    $(this).addClass("active");
                    $(this).parents(".filtrate-sub-check").hide();
                    var val = $(this).attr("value");
                    $(".sxxx").find(".yszc").removeClass("active");
                    $(".sxxx").find(".yszc[value='" + val + "']").addClass("active");
                    /**加载医生信息*/
                    page_ksDetail.initDocInfo();


                }
            })


            /**预约时间*/
            $("#yysj").on("click", function () {
                $(this).parents("li").siblings().find(".filtrate-sub-check").hide();
                $("#yysjChildren").toggle();
            });

            $("#yysjChildren").on("click", "li", function () {
                if (!$(this).hasClass("active")) {
                    $(this).siblings("li").removeClass("active");
                    $(this).addClass("active");
                    $(this).parents(".filtrate-sub-check").hide();
                    var val = $(this).attr("value");
                    $("#sliderTimer").find(".time-wrap").removeClass("active");
                    $("#sliderTimer").find(" .time-wrap[value='" + val + "']").addClass("active");
                    /**加载医生信息*/
                    page_ksDetail.initDocInfo();
                }
            })

            $(".bg").click(function () {
                $(".filtrate-sub-check").hide();
            });
        }

        /**筛选显示*/
        function sxShowOrHide() {

            $(".sxxx").toggle();
            var swiper = $(".sx-icon").data("obj");
            swiper.onResize();
        }

        /**加载数据*/
        function initData() {
            /**注册方法jsbridge调用*/
            $.JkcsUtils.jsbridgeRegister("sxShowOrHide", page_ksDetail.sxShowOrHide);
            /**加载医生信息*/
            page_ksDetail.initDocInfo();
        }

        /**加载医生信息*/
        function initDocInfo(selectedDate, domId) {
            var params = {};
            var params1 = {};

            /**获取预约日期*/
            var info = StoreCache.getCache("YYGH_KSINFO");
            /**设置title*/
            $(".title").text(info["depName"]);
            $(document).attr("title", info["depName"]);

            /**加载医生信息*/
            params["hosCode"] = info["hosCode"];
            params["depCode"] = info["depCode"];
            params["oneDepCode"] = info["oneDepCode"];
            params["parentCode"] = info["parentCode"];
            params["pageNum"] = 1;
            params["pageSize"] = 10;
            // 加载门诊信息
            params1["hosCode"] = info["hosCode"];
            params1["depCode"] = info["depCode"];
            params1["oneDepCode"] = info["oneDepCode"];

            if (domId) {
                $(domId)[0].innerHTML = '';
            } else {
                $("#docUl").remove();
                var docUl = $("<ul>").attr({
                    "id": "docUl"
                });
                $("#docDiv").append(docUl);
            }
            // 门诊
            outPatientListHandler(yygh_ksinfo);

        }

        function outPatientListHandler(yygh_ksinfo) {
            $("#docUl").prepend(template("outpatientInfo", yygh_ksinfo));
            $("#docUl").append(template("outpatientInfo1", yygh_ksinfo));
            $("#docUl .outpatient-service:eq(0) a").on("click", function() {
                var item = {};
                item = yygh_ksinfo;
                item["orderType"] = "2";
                item["resourceCode"] = "SXZZ";
                toYsDetail(JSON.stringify(item));

            });
            $("#docUl .outpatient-service:eq(1) a").on("click", function() {
                $.pageSwitch.goToUrl("myOrder", "ksDetail");

            });
        }


        function doctorListHandler(result, obj) {
            var lis = [];
            var info = StoreCache.getCache("YYGH_KSINFO");
            result["doctors"].forEach(function (arr) {

                var docLi = "";
                docLi = $($("#docyhLi").html());
                //                if(item["scheduleDate"]){
                //                    docLi = $($("#docyhLi").html());
                //                }else{
                //                    docLi = $($("#docwhLi").html());
                //                }
                $(docLi).find(".docImgUrl").attr("src", "/static/images/doctor_image.jpg");
                $(docLi).find(".docName").text(arr["docName"]);
                $(docLi).find(".docTitle").text(arr["regType"]);
                var docInfo = arr["docInfo"] ? arr["docInfo"] : "";
                $(docLi).find(".docSpecialty").text("简介:" + docInfo);
                //                var fee =  parseInt(item["visitCost"]).toFixed(2);
                //                $(docLi).find(".fee").text("￥"+fee);
                //                $(docLi).find(".docSpecialty").text(item["docSpecialty"]);
                arr["orderType"] = "1";
                $(docLi).find("a").attr("onclick", "toYsDetail('" + JSON.stringify(arr) + "')");
                lis.push($(docLi).prop("outerHTML"));

            });
            /*if(JSON.stringify(result["data"])=="{}"){
                lis.push($("#noInfo").html());
            }*/
            obj.next(lis.join(''), false);
        }
        /**设置预约挂号日期 当前日期往后退7天*/



        function setYyghDate() {
            var currDate = new Date();
            var year1 = -1,
                year2 = -1;
            for (var i = 1; i <= 7; i++) {
                var date = currDate.DateAdd("d", i);
                year1 = date.getFullYear();
                if (year1 != year2 && year2 != -1 && !showTime) {
                    showTime = true;
                    formatTime = "MM-dd";
                    $("#timeSchedule").empty();
                    page_ksDetail.setYyghDate();
                    break;
                }
                year2 = year1;
                var dateDiv = $($("#dateDiv").html());
                dateDiv.find(".text-week").html(date.getWeekDay());
                dateDiv.find(".text-time").html(date.Format(formatTime));
                dateDiv.find(".time-wrap").attr("value", date.Format("yyyy-MM-dd"));
                // dateDiv.appendTo($("#timeSchedule"));
                dateDiv.appendTo($("#timeSchedule"));
                var li = $("<li><a href='javascript:void(0);'></a></li>");
                $(li).attr("value", date.Format("MM-dd"));
                $(li).find("a").html(date.Format(formatTime) + " " + date.getWeekDay());
                $(li).appendTo($("#yysjUl"));
                if (i == 1) {
                    dateDiv.trigger("click");
                }
            }
        }


        var cfg_def = {
            initData: initData,
            initView: initView,
            // switchcCntent: switchcCntent,
            sxShowOrHide: sxShowOrHide,
            initDocInfo: initDocInfo,
            doctorListHandler: doctorListHandler,
            setYyghDate: setYyghDate,
            outPatientListHandler,
            outPatientListHandler
        }

        page_ksDetail.init = function (cfg) {
            $.extend(page_ksDetail, cfg_def, cfg);
            page_ksDetail.initData();
            page_ksDetail.initView();
            // $('#ListTab li').click(page_ksDetail.switchcCntent)
        }

        return page_ksDetail;
    })(jQuery, {});
</script>

</html>